package com.xidian.zhiancloud.service.myyb;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.SysJobTableMapper;
import com.xidian.zhiancloud.dao.SysJobTableMapperExt;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.SysJobTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 岗位管理
 */
@Service
public class IJobTableService extends ServiceImpl
        <SysJobTableMapper, SysJobTable> implements IService<SysJobTable> {

    @Autowired
    private SysJobTableMapperExt jobTableMapperExt;

    @Autowired
    private SysJobTableMapper jobTableMapper;

    public int deleteByPrimaryKey(Long id) {
        return jobTableMapperExt.deleteByPrimaryKey(id);
    }

    public int insert(SysJobTable record) {
        return jobTableMapperExt.insert(record);
    }

    public int insertSelective(SysJobTable record) {
        return jobTableMapperExt.insertSelective(record);
    }

    public SysJobTable selectByPrimaryKey(Long id) {
        return jobTableMapperExt.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(SysJobTable record) {
        return jobTableMapperExt.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(SysJobTable record) {
        return jobTableMapperExt.updateByPrimaryKey(record);
    }

    public List<SysJobTable> selectJobTableList(Map mapResult) {
        return jobTableMapperExt.selectJobTableList(mapResult);
    }

    public int deleteJobTableById(Long id) {
        return jobTableMapperExt.deleteJobTableById(id);
    }

    public SysJobTable selectByPositionName(String positionName){
        return jobTableMapperExt.selectByPositionName(positionName);
    }

    /**
     * 修改
     * @param jobTable
     */
    public void patchById(SysJobTable jobTable) {
        int result = jobTableMapper.updateByPrimaryKeySelective(jobTable);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

    /**
     * 添加
     * @param jobTable
     */
    public void add(SysJobTable jobTable) {
        int result = jobTableMapper.insert(jobTable);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

}
